package com.py.credit.controller;


import cn.hutool.http.webservice.SoapClient;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import javax.xml.namespace.QName;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by zhk on 2017/11/23.
 */
public class test {
    public static void main(String[] args) throws Exception {
        // 监督检查测试
        csJdjc();
    }

    private static void csJdjc() {
        String wsaddr = "https://222.143.33.180:8443/creditdata/ws/shareDataInterfaceService?wsdl";
        String key = "FE200DC59C9A415FAEA4F42918584AD5";

        try {
            Map<String, Object> params = new HashMap<>();
            params.put("key", key);

            SoapClient soapClient = SoapClient.create(wsaddr)
                    .setMethod("tns:getUnitNames", "http://subjectcenter.service.hncredit.hnrj.com/")
                    .setParams(params, false);
            String send = soapClient.send(true);
          

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static  JSONArray xmlToJSONArray(String xml) throws DocumentException {
        JSONArray list = new JSONArray();
        Document doc = (Document) DocumentHelper.parseText(xml);
        // 获取根节点
        Element root = doc.getRootElement();
        Element elementTotalSize = root.element("totalsize");
        String name11 = root.attributeValue("elementTotalSize");
        System.out.println("#############:"+name11);
        Element element = root.element("datas");
        if (element != null ) {
            List<Element> elementItem = element.elements("data");
            if (elementItem != null) {
                for (Element elementitem : elementItem) {
                    JSONObject object = new JSONObject();
                    List<Element> ele = elementitem.elements("item");
                    for (Element element1 : ele) {
                        String lable = element1.attributeValue("name");
                        String lableValue = element1.getTextTrim();
                        object.put(lable,lableValue);
                    }
                    list.add(object);
                }
            }

        }
        return list;
    }
}
